package test.pcs;

import com.alibaba.fastjson.JSON;
import com.payment.lc.pcs.client.wrap.bo.ProductionAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionPurchaseAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionRedeemAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionValueAttributes;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapService;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapServiceV20;
import com.payment.lc.pcs.common.enums.*;
import com.payment.lc.pcs.common.enums.n.MiProductMainCategory;
import com.payment.lc.pcs.common.util.DateUtil;
import com.payment.lc.pcs.service.api.*;
import com.payment.lc.pcs.service.api.fund.JMFundService;
import com.payment.lc.pcs.service.api.modify.PcsChannelService;
import com.payment.lc.pcs.service.api.nocache.DateComputeService;
import com.payment.lc.pcs.service.api.nocache.PcsQueryService;
import com.payment.lc.pcs.service.bo.*;
import com.payment.lc.pcs.service.domain.*;
import com.payment.lc.pcs.service.request.GetFundListReq;
import com.payment.lc.pcs.service.request.GetProductsReq;
import com.payment.lc.pcs.service.request.ProductQueryReq;
import com.payment.lc.pcs.service.response.BaseResponse;
import com.payment.lc.pcs.service.response.GetFundListResp;
import com.payment.lc.pcs.service.response.PcsCommonPageResp;
import com.payment.lc.pcs.service.response.ProductQueryResp;
import com.payment.lc.pcs.util.DateComputeUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import test.BaseTest;

import java.util.*;

/**
 * Created on 2016/8/8.
 */
public class Demo3PcsRevisionTest6 extends BaseTest {

    @Autowired
    PcsQueryService pcsQueryService;

    @Autowired
    ProductionWrapService productionWrapService;

    @Autowired
    @Qualifier("dynamicDataServiceLocal")
    DynamicDataService dynamicDataServiceLocal;
    @Autowired
    @Qualifier("dynamicDataService")
    DynamicDataService dynamicDataService;

    @Autowired
    JMFundService jmFundService;

    @Autowired
    @Qualifier("productionService")
    ProductionService productionService;

    @Autowired
    @Qualifier("productionServiceLocal")
    ProductionService productionServiceLocal;

    @Autowired
    NoticeService noticeService;
    @Autowired
    AppSettingService appSettingService;

    @Autowired
    ProductionWrapServiceV20 productionWrapServiceV20;
    @Autowired
    ProductionServiceV20 productionServiceV20;

    @Autowired
    DateComputeUtil dateComputeUtil;

    @Autowired
    PcsChannelService pcsChannelService;

    @Autowired
    DateComputeService dateComputeService;

    @Test
    public void test() throws Exception {
        test7();
    }

    void test7() {
        GetProductsReq req = new GetProductsReq();
        req.setExcludeExpiredProduct(null);
        req.setMiMainCategory(MiProductMainCategory.FI);
        PcsCommonPageResp<String> products = pcsQueryService.getProductsByCategories(req);
        display(products);
    }
    void test6() {
        String prodCode = "FI16025";
        Production production = productionService.getProduction(prodCode);
        ProductionPurchaseAttributes purchaseAttributes = productionWrapService.getProductionPurchaseAttributes(production);
        display(purchaseAttributes);
    }
    void test5() {
        String prodCode = "FI16025";
        ProductionValue value = dynamicDataService.getProductionValue(prodCode);
        display(value);

        Production production = productionService.getProduction(prodCode);
        ProductionValueAttributes valueAttributes = productionWrapService.getProductionValueAttributes(production);
        display(valueAttributes);

//        pcsChannelService.syncFundMPValue("JM000709");
//        pcsChannelService.syncProductState("JM000709", null);
//        pcsChannelService.syncProductState(null, "HK102");
    }

    void test1() {
        TreeSet<MiProductCategory> set = new TreeSet<>();
        set.add(MiProductCategory.YueGuJiao);
        TreeSet<DisplayType> displayTypes = new TreeSet<>();
        displayTypes.add(DisplayType.Init);
        displayTypes.add(DisplayType.Down);
        List<Production> productionsByCategoryDisplayType = productionWrapServiceV20.getProductionsByCategoryDisplayType(set, displayTypes);
        display(productionsByCategoryDisplayType);
    }

    void test3() {
        String s = "{\"displayType\":\"Up\",\"excludeProducts\":[\"FI16022\",\"FI16025\",\"FI16021\",\"FI16020\",\"CS20170926\"],\"limit\":10,\"miMainCategory\":\"FI\",\"productLevel\":\"Item\",\"providerCode\":\"null\",\"start\":0}";
        GetProductsReq req = JSON.parseObject(s, GetProductsReq.class);
        PcsCommonPageResp<String> resp = pcsQueryService.getProductsByCategories(req);
        display(resp);
    }
    void test4() {
        GetProductsReq req = new GetProductsReq();
        req.setStart(0);
        req.setLimit(100);
        req.setMiMainCategory(MiProductMainCategory.FI);
        ArrayList<String> exclude = new ArrayList<>();
        exclude.add("FI16014");
        req.setExcludeProducts(exclude);
//        req.setOnSale(true);
        req.addOrderByItem(null, GetProductsReq.OrderType.DESC);
        req.setDisplayType(DisplayType.Up);
//        req.setMiCategory(MiProductCategory.YueGuJiao);
        PcsCommonPageResp<String> resp = pcsQueryService.getProductsByCategories(req);
        display(resp);
    }

    void test2() {
        ListWrapper<String> codes = productionServiceV20.getProdCodesByCategoryDisplayType(MiProductCategory.YueGuJiao, DisplayType.Init);
        display(codes);
    }

}